import { prop, Ref, arrayProp } from '@typegoose/typegoose'
import { ApiModelProperty } from '@nestjs/swagger'
import { IsNotEmpty } from 'class-validator'
import { Permission } from './permission.model'

enum methods {
  GET = 'get',
  POST = 'post',
  DELETE = 'delete',
  PUT = 'put',
  OPTIONS = 'options'
}


export class Role {
  @ApiModelProperty({ description: '角色名字', example: '管理员' })
  @prop()
  @IsNotEmpty({ message: '请填写角色名称' })
  name!: string

  @ApiModelProperty({ description: '角色备注', example: '啥都能干,为所欲为' })
  @prop()
  @IsNotEmpty({ message: '请填写角色说明' })
  description!: string

  @ApiModelProperty({ description: '角色状态', example: '正常' })
  @prop()
  @IsNotEmpty({ message: '请选择角色状态' })
  status!: string

  @ApiModelProperty({ description: '角色权限', example: ['Object._id', 'Object._id'], type: [String], required: false })
  @arrayProp({ itemsRef: Permission })
  permission?: Ref<Permission> []
}
